{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#                    HW1 线性回归 共享单车数量预测\n",
    "Capital Bikeshare 提供的自行车数据上进行回归分析，训练数据为2011年，预测2012年的单车共享数量。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1、导入必要的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "# 图形出现在Notebook里而不是新窗口\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2、数据探索"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.1 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011/1/1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011/1/2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011/1/3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011/1/4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011/1/5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant    dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011/1/1       1   0     1        0        6           0   \n",
       "1        2  2011/1/2       1   0     1        0        0           0   \n",
       "2        3  2011/1/3       1   0     1        0        1           1   \n",
       "3        4  2011/1/4       1   0     1        0        2           1   \n",
       "4        5  2011/1/5       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 231,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 读取数据\n",
    "#dpath =r'C:\\Users\\N\\Desktop'\n",
    "#将数据day.csv放入到本code的同一文件夹后，直接调用csv文件\n",
    "data = pd.read_csv(\"day.csv\")\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(731, 16)"
      ]
     },
     "execution_count": 232,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.3数据分析\n",
    "根据0_EDA_CapitalBikeshare_amount.ipynb\n",
    "对于影响目标y的特征X进行分析\n",
    "1、casul+registered的数据=cnt 故不做X特征向量\n",
    "2、dteday和instant 根据数据分析，也不做特征向量 \n",
    "3、atemp和temp 强度相关1.0 故取temp向量作为特征向量X\n",
    "4、mnth,weathersit,weekday,weathersit为类别型的特征向量，做one-hot编码\n",
    "5、针对cnt大于8000可能为噪声，去除离群点。\n",
    "6、针对temp大于40的可能为噪声，去除。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.4 数据准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "data = data[data.cnt < 8000]\n",
    "data=data[data.temp<40]\n",
    "y = data['cnt']\n",
    "X=data.drop(['dteday','instant','temp','casual','registered','cnt'],axis=1)\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 251,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#分割train和test，根据csv发现，前364为2011年数据，后为2012年数据，根据要求，划分\n",
    "X_train=X.ix[:364]\n",
    "X_test=X.ix[365:]\n",
    "y_train=y.ix[:364].values\n",
    "y_test=y.ix[365:].values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "类比型归一化\n",
    "yr只有0和1 不做编码，holiday，workingday 同理\n",
    "分别对season，mnth，weekday，weathersit做类别归一\n",
    "采用pd.get_dummies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 252,
   "metadata": {},
   "outputs": [],
   "source": [
    "X=pd.get_dummies(X,columns=['season']) \n",
    "X=pd.get_dummies(X,columns=['mnth']) \n",
    "X=pd.get_dummies(X,columns=['weekday']) \n",
    "X=pd.get_dummies(X,columns=['weathersit'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "数值型归一化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import StandardScaler\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.transform(X_test)\n",
    "#y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "#y_test = ss_y.transform(y_test.reshape(-1, 1))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 267,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8.758677e+02</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4.129074e+02</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.066048e+01</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1.127682e+01</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-1.136868e-13</td>\n",
       "      <td>yr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-7.029947e+00</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-4.243126e+01</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-9.139744e+01</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-1.546907e+02</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-3.017858e+02</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           coef     columns\n",
       "7  8.758677e+02       atemp\n",
       "0  4.129074e+02      season\n",
       "4  5.066048e+01     weekday\n",
       "5  1.127682e+01  workingday\n",
       "1 -1.136868e-13          yr\n",
       "2 -7.029947e+00        mnth\n",
       "3 -4.243126e+01     holiday\n",
       "8 -9.139744e+01         hum\n",
       "9 -1.546907e+02   windspeed\n",
       "6 -3.017858e+02  weathersit"
      ]
     },
     "execution_count": 267,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True,normalize=False,copy_X=True,n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 262,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is -0.6714770371170435\n",
      "The r2 score of LinearRegression on train is 0.7557892552582139\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print ('The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print ('The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "R2_score为负值，利用train_test_split从训练集中分出一部分做校验集，进行测试时R2_score为正，初步猜测和2011、2012的样本值有一定关系。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 263,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe4AAAFsCAYAAAAKb1qFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAE8dJREFUeJzt3X+MZWd5H/Dvw+7irYIRtnegLmt3TYoijGRstHKQaAPFCTGoBVvaqIBEl4bIURVLYKKqbvxHt1KRHOqAGhFBjYxiJH6EFhAWSkpcA6KGxnShjrG7uDbEhA2Lvdih2I1MMTz9Y85Ww3pmZ3bmzo935/ORrubc95xz73PfuXO/95z73nequwMAjOEZm10AALByghsAB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9vl4kjdMy+9P8s83+/FttUuSF2V+IqAvJNm/oF1/b/zvYsm+dVlVf/5SkpcmuXdB27uSXD8tX7/g9eW1Sf4k8/NxvCzJXVP7uUm+Nf08Z1o+Z7Mf21a8JDk/yUun5bOT/K/pdWTd+9wR9ybr7j/t7qemq3+W+e/DJ/PTx36su3/U3X+R5MHMTzO76FSzVVVJXpXkP03735rkqo16HKPo7iPdvdjsffp745k2eYa6+4tJHjup+fWZf24mP/scfX2SD/W8P0vynKo6P8mvJrm9ux/r7r9OcnuSK9e/+vF097Hu/tq0/HiSI0menw3oc8G9tfx65t+RJfNPgO8sWHd0aluq/bwkP1jwJuBEOyujvzfeUn3L7Dyvu48l80GT5LlT++k+3zmFqtqX5LIkd2UD+nwtU56yQlX1X5L87UVW3dDdn562uSHJU0k+fGK3RbbvLP5mq0+x/bazkv5ebLdF2vT3+tKHm2epvvc7OU1V9awkn0jy9u7+4fzJuMU3XaRtVX0uuDdAd//yqdZPgxH+UZIrevrQI6eeUnax9u9n/tTLzukocNtOQbtcfy9Bf2880yavv4er6vzuPjadln1kal+q748meeVJ7V/YgDqHVFW7Mh/aH+7uT07N697nTpVvsqq6Msm/TPK67v6bBatuS/KGqjqrqi5K8sIkX8kSU81Ogf/5JAem/Q8mWerokqfT3xvPtMnr77bMPzeTn32O3pbkn04jnV+W5H9Pp3U/m+TVVXXONBr61VMbJ5nGudyS5Eh3v3vBqvXv880embfdL5kfBPWdJHdPl/cvWHdD5kfd3p/kNQvaX5v5EYzfzPzp3xPtL8h82DyY5D8mOWuzH99WuyS5OvPvcH+U5OEkn9Xfm/r7WLRvXVbVlx9NcizJj6fn+FszPxbjjiQPTD/PnbatJH8w9fvX87PfsPj16Tn9YJJ/ttmPa6tekvz9zJ/SvmfB6/drN6LPTXkKAANxqhwABiK4AWAgghsABiK4AWAgghsABiK4AWAgghsABvL/AMorcbe8X87uAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xd0d27b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='cnt', color='b', alpha=.5); \n",
    "ax.set_title(\"cnt\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "残差分布和高斯分布比较匹配,-2000部分应该是残差。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 264,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJztnX2YHGWV6H9nOp3QEyQzkagwEgPKDQuLITFKNHt9TFyJylfED2DdXfS6611lV0CfaOLymLjqQzSuoLt7/biCF1dWAzGOfKgRId518QZMnIQYSZavgExYiSaDQAYymTn3j3prqO6pqq6uruqvOb/n6aer36quOj3Tdfo95z0foqoYhmHkQVezBTAMo3MxBWMYRm6YgjEMIzdMwRiGkRumYAzDyA1TMIZh5IYpGMMwcsMUjGEYuWEKxjCM3JjSbAHy4Nhjj9U5c+Y0WwzD6Fi2bdv2O1WdVe24jlQwc+bMYevWrc0WwzA6FhF5JMlxZiIZhpEbuSoYEekRkQ0isltE7hOR14rITBG5XUTud8+97lgRkS+JyAMicq+ILAic5xJ3/P0ickmeMhuGkR15z2C+CPxIVU8B5gH3ASuBO1T1ZOAO9xrgLcDJ7vF+4MsAIjITWA2cCbwGWO0rJWPy0T8wyOK1d3LiyttYvPZO+gcGmy2SEUNuCkZEjgFeD1wLoKqHVXUIOB+43h12Pb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gnf9hsnQ9Ju9WQ88j/l/4vkG/j7D834beBwYwdP878Oz5e8A7nfPM92xgtdQ7kFgJ7AwcJ7/ATzgHu+tUYY/wZvC3gtsd4+3NkoO4JXAgLv+r4BPuPGTgHvcuW4Cprnxo9zrB9z+kwLn+nsn1x7gLSn/J2/geQXTEBncdXa4xy7/O9aE78IZwFb3v+h3CqJhMliqgGEYuTFZfTCGYTQAUzCGYeSGKRjDMHLDFIxhGLlhCsYwjNxom8ZrRusgIv4yJ8BLgFG8kHSA16jq4SbJtRQ4pKpbmnF9YyKmYIyaUdXf48VXICJrgKdV9fPBY0RE8JLsxiaeITeW4iUpmoJpEcxEMjJDRF4hIr8Ska/gZVCfICJDgf0XicjX3faLRWSjiGx1tWMWhZxviohc7c55r4h80I0/JiJrXALfvSLy30Tk5cBfAStc/ZXXNeZTG3HYDMbImlPxIj3/JpDzE8aX8ELUt7iM71uBP6445gPA8cA8VR0VkZmBfb9V1fki8iHgw+56Xwd+p6rXZPZpjLowBWNkzYOq+osEx/0pMNezpADoFZGSqg5XHHONqo4CqOqBwD4/gXMbXhqE0YKYgjGy5pnA9hjlqf5HBbaF6g5hIboswHPueRT7Hrcs5oMxcsM5eA+KyMki0gW8LbD7J3gZzACIyBkhp/gx8AERKbhjZoYcE+QpvBKhRotgCsbIm48BP8Jb1n4sMH4psNg5aX8N/HXIe78K/Bdwr4jsAN5V5VrfB97lnL/m5G0BLJvaMIzcsBmMYRi5YQrGMIzcMAVjGEZumIIxDCM3TMEYhpEbpmAMw8gNUzCGYeTG/wemte3R9lvAzQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xbf51240>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True cnt')\n",
    "plt.ylabel('Predicted cnt')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在y的真值在2000-3000和4000-5000效果不好，有很多的离群点。"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "3正则化的线性回归（L2正则 --> 岭回归）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is -0.6813517786659276\n",
      "The r2 score of RidgeCV on train is 0.7553591096915865\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "#ridge_params_ = { 'max_iter':[3000],\n",
    "                 #'alphas':[0.1, 1, 2, 3, 4, 10, 30,100,200,300,400,800,900,1000]}\n",
    "alphas = [0.001,0.01, 0.1, 1, 10,100,1000]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)\n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)\n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print( 'The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print( 'The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaEAAAEKCAYAAAC7c+rvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh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/OKD8M/Hqo/znggYz6zcDy8z9VkfOjCUxFcm8Z8Ji79wKHzOx54GOh/F/cvQ9418x+mrHPdCCR8f23zGwNqf9npwNXADv6tdMHfDd8/icgcwLN9OftpIIPUuvE/C8zuxroBS7LqH8YKNpVgKV4KIREci/b0guDlQOcAsYAmNlc4E+Aj7l7p5k9kt42hMw5uc6E915++f/9H5Oar+0qUndFTmfUHxP6IJJTuh0nknsx4HNhobB6YAXwIqllk38zPBu6iNREnmm7gAXh8yTgJHA01LtlgHYqgPQzpd8Oxx/MZOBguBL7D6QmrEy7jBxN3S+SSVdCIrn3fVLPe14jdXXyp+7+bphh/UZSf9i3kFqF82jY5wekQunH7v6amb0C7AT2AJsHaOckcKWZbQ/H+dwQ/fo28JSZ3Qb8NOyf9quhDyI5pVm0RSJkZhPc/YSZ1ZK6OloaAmosqWBYGp4lDedYJ9x9wgXqVwxY5e6dF+J4IgPRlZBItP41LCBWDdzv7u8CuPspM1sLzAD25bND4ZbhXyuAJB90JSQiIpHRwAQREYmMQkhERCKjEBIRkcgohEREJDIKIRERiYxCSEREIvP/AYlAZODM4QyhAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xbe7bb00>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 10.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8.758677e+02</td>\n",
       "      <td>854.070353</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4.129074e+02</td>\n",
       "      <td>388.342876</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.066048e+01</td>\n",
       "      <td>47.621919</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1.127682e+01</td>\n",
       "      <td>11.596032</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-1.136868e-13</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>yr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-7.029947e+00</td>\n",
       "      <td>19.181051</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-4.243126e+01</td>\n",
       "      <td>-42.722461</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-9.139744e+01</td>\n",
       "      <td>-88.409084</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-1.546907e+02</td>\n",
       "      <td>-152.780765</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-3.017858e+02</td>\n",
       "      <td>-296.983454</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        coef_lr  coef_ridge     columns\n",
       "7  8.758677e+02  854.070353       atemp\n",
       "0  4.129074e+02  388.342876      season\n",
       "4  5.066048e+01   47.621919     weekday\n",
       "5  1.127682e+01   11.596032  workingday\n",
       "1 -1.136868e-13    0.000000          yr\n",
       "2 -7.029947e+00   19.181051        mnth\n",
       "3 -4.243126e+01  -42.722461     holiday\n",
       "8 -9.139744e+01  -88.409084         hum\n",
       "9 -1.546907e+02 -152.780765   windspeed\n",
       "6 -3.017858e+02 -296.983454  weathersit"
      ]
     },
     "execution_count": 197,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    " #看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这里在alphas = [0.001,0.01, 0.1, 1, 10,100,1000]的范围内寻找的最优正则参数alphas=10.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 268,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is -0.8338176572302265\n",
      "The r2 score of LassoCV on train is 0.6845451785239587\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "'''class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "                                   normalize=False, precompute=’auto’, max_iter=1000, \n",
    "                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "                                   positive=False, random_state=None, selection=’cyclic’)'''\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "alphas = [ 0.001,0.01, 0.1, 1, 10,100,1000]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaEAAAEKCAYAAAC7c+rvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VdXV+P/PypyQERICJIEwBJmUKQqKMw5oW7FWrdYBrUprtVU7atunfKv99bGt1Vattg5UbLVqlSpVkQecJ4aAyGAEwhwISUhCyEAISdbvj7uj15jhJuTmZFjv1+u+cu4++5y9Ti7clbPPPvuIqmKMMcZ4IcTrAIwxxvRdloSMMcZ4xpKQMcYYz1gSMsYY4xlLQsYYYzxjScgYY4xnLAkZY4zxjCUhY4wxnrEkZIwxxjNhwdqxiEQB7wCRrp3nVXWeiDwFZANHgJXAd1T1iIgI8GfgfKAauEZV17h9zQF+6Xb9G1Vd4MqnAk8A0cCrwC2qqiLSH3gWyAR2AJe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PGNJyBhjjGcsCRkTJCJS2XatVrd/XkRGtFHnLRHJPto6TeqniMhrgdY35mhYEjKmG3JzjoWq6raubltVi4ECEZnR1W2bvseSkDFB5mYC+IOIbBCR9SLyTVceIiIPuee5vCwir4rIxW6zK4CX/PbxsIjktPTsF1enUkT+KCJrROR1EUnxW32Je37MZhE5xdXPFJF3Xf01InKSX/0XXQzGBJUlIWOC7yJgEjAR3/Qof3BTIV0EZALHAtcDJ/ptMwNY7ff+F6qaDRwHnCYixzXTTj9gjapOAd7GN8tCozBVPQG41a+8CDjb1f8mcL9f/RzglPYfqjHtY9P2GBN8JwP/UtV6oFBE3gaOd+X/VtUGYJ+IvOm3zWCg2O/9pSIyF9//2cHAOGBdk3YagGfd8j8B/wk2G5dX40t84JsG6EERmQTUA6P96hcBQ9p5nMa0myUhY4KvpQeBtfaAsENAFICIDAd+DByvqmUi8kTjujb4z8nVOAt6PZ//v78NKMR3hhYC1PjVj3IxGBNU1h1nTPC9A3zTPUQsBd+ju1cC7+F7WGCIiKTim7C0US4wyi3HA1VAuat3XgvthOCbQBPgW27/rUkACtyZ2FX4JrBtNBrYEMCxGXNU7EzImOD7D77rPR/jOzv5qaruE5EXgJn4vuw343tKZ7nb5hV8SWmZqn4sIh8BG4FtwPsttFMFjBeR1W4/32wjroeAF0TkEuBNt32jM1wMxgSVzaJtjIdEJFZVK0VkAL6zoxkuQUXjSwwz3LWkQPZVqaqxnRTXO8BsVS3rjP0Z0xI7EzLGWy+7h4tFAHep6j4AVT0kIvOANGBXVwbkugzvtQRkuoKdCRljjPGMDUwwxhjjGUtCxhhjPGNJyBhjjGcsCRljjPGMJSFjjDGesSRkjDHGM/8/UX44XcOuTuAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xbf217b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 214.48034686768793\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>740.216592</td>\n",
       "      <td>8.758677e+02</td>\n",
       "      <td>854.070353</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>253.736652</td>\n",
       "      <td>4.129074e+02</td>\n",
       "      <td>388.342876</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>5.066048e+01</td>\n",
       "      <td>47.621919</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.127682e+01</td>\n",
       "      <td>11.596032</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.136868e-13</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>yr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-7.029947e+00</td>\n",
       "      <td>19.181051</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-4.243126e+01</td>\n",
       "      <td>-42.722461</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-9.139744e+01</td>\n",
       "      <td>-88.409084</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>-1.546907e+02</td>\n",
       "      <td>-152.780765</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-161.028739</td>\n",
       "      <td>-3.017858e+02</td>\n",
       "      <td>-296.983454</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   coef_lasso       coef_lr  coef_ridge     columns\n",
       "7  740.216592  8.758677e+02  854.070353       atemp\n",
       "0  253.736652  4.129074e+02  388.342876      season\n",
       "4    0.000000  5.066048e+01   47.621919     weekday\n",
       "5    0.000000  1.127682e+01   11.596032  workingday\n",
       "1    0.000000 -1.136868e-13    0.000000          yr\n",
       "2    0.000000 -7.029947e+00   19.181051        mnth\n",
       "3   -0.000000 -4.243126e+01  -42.722461     holiday\n",
       "8   -0.000000 -9.139744e+01  -88.409084         hum\n",
       "9   -0.000000 -1.546907e+02 -152.780765   windspeed\n",
       "6 -161.028739 -3.017858e+02 -296.983454  weathersit"
      ]
     },
     "execution_count": 203,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaEAAAEKCAYAAAC7c+rvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VdXV+P/PypyQERICJIEwBJmUKQqKMw5oW7FWrdYBrUprtVU7atunfKv99bGt1Vattg5UbLVqlSpVkQecJ4aAyGAEwhwISUhCyEAISdbvj7uj15jhJuTmZFjv1+u+cu4++5y9Ti7clbPPPvuIqmKMMcZ4IcTrAIwxxvRdloSMMcZ4xpKQMcYYz1gSMsYY4xlLQsYYYzxjScgYY4xnLAkZY4zxjCUhY4wxnrEkZIwxxjNhwdqxiEQB7wCRrp3nVXWeiDwFZANHgJXAd1T1iIgI8GfgfKAauEZV17h9zQF+6Xb9G1Vd4MqnAk8A0cCrwC2qqiLSH3gWyAR2AJeqallrbbQkOTlZMzMzj/4XYowxfcjq1av3q2pKW/UkWNP2uC/8fqpaKSLhwHvALUB/YLGr9jTwjqo+LCLnA9/HlyCmAX9W1WkuoeTgS1wKrAamuqSy0u1zOb4kdL+qLhaR3wOlqnq3iNwOJKnqz1pqo7XjyM7O1pycnM77xRhjTB8gIqtVNbutekHrjlOfSvc23L1UVV916xTfmVC6qzMbeNKtWg4kishg4FxgqaqWqmoZsBSY5dbFq+qHbl9PAhf67WuBW17QpLy5NowxxnggqNeERCRURNYCRfgSyQq/deHAVcBrrigN2O23e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mcL9f/RzglPYfqjHtY9P2GBN8JwP/UtV6oFBE3gaOd+X/VtUGYJ+IvOm3zWCg2O/9pSIyF9//2cHAOGBdk3YagGfd8j8B/wk2G5dX40t84JsG6EERmQTUA6P96hcBQ9p5nMa0myUhY4KvpQeBtfaAsENAFICIDAd+DByvqmUi8kTjujb4z8nVOAt6PZ//v78NKMR3hhYC1PjVj3IxGBNU1h1nTPC9A3zTPUQsBd+ju1cC7+F7WGCIiKTim7C0US4wyi3HA1VAuat3XgvthOCbQBPgW27/rUkACtyZ2FX4JrBtNBrYEMCxGXNU7EzImOD7D77rPR/jOzv5qaruE5EXgJn4vuw343tKZ7nb5hV8SWmZqn4sIh8BG4FtwPsttFMFjBeR1W4/32wjroeAF0TkEuBNt32jM1wMxgSVzaJtjIdEJFZVK0VkAL6zoxkuQUXjSwwz3LWkQPZVqaqxnRTXO8BsVS3rjP0Z0xI7EzLGWy+7h4tFAHep6j4AVT0kIvOANGBXVwbkugzvtQRkuoKdCRljjPGMDUwwxhjjGUtCxhhjPGNJyBhjjGcsCRljjPGMJSFjjDGesSRkjDHGM/8/UX44XcOuTuAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xbcebe48>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 214.48034686768793\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这里在alphas = [0.001,0.01, 0.1, 1, 10,100,1000]的范围内寻找的最优正则参数alphas=214.480"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "最后尝试用随机森林进行预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RF on train is 0.9738806167939882\n",
      "The r2 score of RF on test is -0.5678494770618736\n"
     ]
    }
   ],
   "source": [
    "#随机森林\n",
    "from sklearn.ensemble import RandomForestRegressor\n",
    "rfModel = RandomForestRegressor(n_estimators=10)\n",
    "#yLabelsLog = np.log1p(yLabels)\n",
    "rfModel.fit(X_train,y_train)\n",
    "preds1=rfModel.predict(X_train)\n",
    "preds = rfModel.predict(X_test)\n",
    "print ('The r2 score of RF on train is', r2_score(y_train,preds1))\n",
    "print ('The r2 score of RF on test is', r2_score(y_test,preds))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
